﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Globalization;

namespace IronLua
{
    internal static class ValueExtensions
    {
        public static bool TryGetLiteralString(this Value value, out string str)
        {
            if (value.IsString)
            {
                str = value.String ?? "";
                return true;
            }

            if (value.IsNumber)
            {
                str = value.Number.ToString(CultureInfo.InvariantCulture);
                return true;
            }

            str = null;
            return false;
        }

        public static string GetTypeString(this Value value)
        {
            return value.Type.ToString().ToLowerInvariant();
        }

    }
}
